<?php
//include_once(path_format('config/config.php'));
function rc4($pwd, $data){
			$key[] ="";
			$box[] ="";
			$cipher = "";
			$pwd_length = strlen($pwd);
			$data_length = strlen($data);
		 
			for ($i = 0; $i < 256; $i++)
			{
				$key[$i] = ord($pwd[$i % $pwd_length]);
				$box[$i] = $i;
			}
		 
			for ($j = $i = 0; $i < 256; $i++)
			{
				$j = ($j + $box[$i] + $key[$i]) % 256;
				$tmp = $box[$i];
				$box[$i] = $box[$j];
				$box[$j] = $tmp;
			}
		 
			for ($a = $j = $i = 0; $i < $data_length; $i++)
			{
				$a = ($a + 1) % 256;
				$j = ($j + $box[$a]) % 256;
		 
				$tmp = $box[$a];
				$box[$a] = $box[$j];
				$box[$j] = $tmp;
		 
				$k = $box[(($box[$a] + $box[$j]) % 256)];
				$cipher .= chr(ord($data[$i]) ^ $k);
			}
			 
			return $cipher;
}


//二维数组转一维数组
function arrToOne($multi){
	$arr = array();
	foreach($multi as $key=>$val){
		if(is_array($val)){
			$arr = array_merge($arr,arrToOne($val));
		}else{
			$arr[] = $val;
		}
	}
	return $arr;
}

//过滤表情
function filter_emoji($str) { 
		$str = preg_replace_callback(
            '/./u',
            function (array $match) {
                return strlen($match[0]) >= 4 ? '' : $match[0];
            },
            $str);

     return $str;

}

//自动加载类库
function autoload($className){
    $fileName = strtolower($className.'.php');
    require $fileName;   
}




